﻿@*@model IEnumerable<OMS.Models.ItemModelView>*@
@model PagedList.IPagedList<OMS.Models.ItemModelView>

@{
    ViewBag.Title = "GetAllItems";
}

<h2>GetAllItems</h2><br />
Total: @ViewBag.TotalItems items

<table align=center>
    <tr>
        <th>Item Number</th>
        <th>Name</th>
        <th>Description</th>
        <th>Price</th>
        <th>Quantity</th>
        <th></th>
    </tr>

@foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(i => item.Id)
            </td>
            <td>
                @Html.DisplayFor(i => item.Name)
            </td>
            <td>
                @Html.DisplayFor(i => item.Description)
            </td>
            <td>
                @Html.DisplayFor(i => item.Price)
            </td>
            <td>
                @Html.DisplayFor(i => item.Quantity)
            </td>
            <td>
                @Html.ActionLink("Edit", "EditItem", new { id = item.Id })
                @Html.ActionLink("Delete", "DeleteItem", new { id = item.Id })
                @Html.ActionLink("Details", "GetItem", new { id = item.Id })
            </td>
        </tr>
    }
</table>

<div align=center>
    Page @(Model. PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount
     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("First", "GetAllItems", new { page = 1 })
        @Html.Raw(" ");
        @Html.ActionLink("< Prev", "GetAllItems", new { page = Model.PageNumber - 1 })
    }
    else
    {
        @:First
        @Html.Raw(" ");
        @:< Prev
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Next >", "GetAllItems", new { page = Model.PageNumber + 1 })
        @Html.Raw(" ");
        @Html.ActionLink("Last", "GetAllItems", new { page = Model.PageCount })
    }
    else
    {
        @:Next >
        @Html.Raw(" ")
        @:Last
    }
</div>



@Html.ActionLink("New item", "AddItem")
